/**
 * ...
 * @author Rob Dravenstott
 */

class GraphicUtils 
{
	
	public static function createRect(mc:MovieClip, name:String, x:Number, y:Number, width:Number, height:Number, fill:Number, transparency:Number, lineWidth:Number):Void
	{
		mc.createEmptyMovieClip(name, mc.getNextHighestDepth());
		mc[name].beginFill(fill, transparency);
		if ((lineWidth != undefined)
		    && (lineWidth > 0))
			mc[name].lineStyle(lineWidth, 0xFFFFFF, 100);
		mc[name].moveTo(x, y);
		mc[name].lineTo(x+width, y);
		mc[name].lineTo(x+width, y+height);
		mc[name].lineTo(x, y+height);
		mc[name].lineTo(x, y);
		mc[name].endFill();
	}
	
	public static function createTextArrows(mc:MovieClip, tf:TextFormat, text_bottom_mc_name:String, text_field_mc_name:String, name_up:String, name_down:String, x:Number, y:Number, text_width:Number)
	{
		mc.createTextField(text_bottom_mc_name, mc.getNextHighestDepth(), x, y, text_width+15, 30);
		tf.size = 20;
		tf.align = "left";
		mc[text_bottom_mc_name].setNewTextFormat(tf);
		
		mc.createTextField(text_field_mc_name, mc.getNextHighestDepth(), x, y+30, text_width, 28);
		tf.size = 20;
		mc[text_field_mc_name].setNewTextFormat(tf);
		mc[text_field_mc_name].background = true;
		mc[text_field_mc_name].backgroundColor = 0x999999

		GraphicUtils.createUpDownArrows (mc, name_up, name_down, x+text_width+10, y+40, 0xFFFFFF, 100);
	}
	
	public static function createUpDownArrows (mc:MovieClip, name_up:String, name_down:String, x:Number, y:Number, fill:Number, transparency:Number):Void
	{
		var vertical_spacer:Number = 9;
		var name_up_drawing = name_up + "_drawing";
		var name_down_drawing = name_down + "_drawing";
		var width:Number = 44;
		var height:Number = 36;
		
		mc.createEmptyMovieClip(name_up_drawing, mc.getNextHighestDepth());
		mc[name_up_drawing].beginFill(fill, transparency);
		mc[name_up_drawing].moveTo(x, y);
		mc[name_up_drawing].lineTo(x+width, y);
		mc[name_up_drawing].lineTo(x+width/2, y-height);
		mc[name_up_drawing].lineTo(x, y);
		mc[name_up_drawing].endFill();

		mc.createEmptyMovieClip(name_up, mc.getNextHighestDepth());
		mc[name_up].beginFill(0x000000, 0);
		mc[name_up].moveTo(x-10, y-height-10);
		mc[name_up].lineTo(x+width+10, y-height-10);
		mc[name_up].lineTo(x+width+10, y);
		mc[name_up].lineTo(x-10, y);
		mc[name_up].lineTo(x-10, y-height-10);
		mc[name_up].endFill();
		
		mc.createEmptyMovieClip(name_down+"_drawing", mc.getNextHighestDepth());
		mc[name_down_drawing].beginFill(fill, transparency);
		mc[name_down_drawing].moveTo(x, y+vertical_spacer);
		mc[name_down_drawing].lineTo(x+width, y+vertical_spacer);
		mc[name_down_drawing].lineTo(x+width/2, y+vertical_spacer+height);
		mc[name_down_drawing].lineTo(x, y+vertical_spacer);
		mc[name_down_drawing].endFill();
		
		mc.createEmptyMovieClip(name_down, mc.getNextHighestDepth());
		mc[name_down].beginFill(0x000000, 0);
		mc[name_down].moveTo(x-10, y+vertical_spacer);
		mc[name_down].lineTo(x+width+10, y+vertical_spacer);
		mc[name_down].lineTo(x+width+10, y+vertical_spacer+height+10);
		mc[name_down].lineTo(x-10, y+vertical_spacer+height+10);
		mc[name_down].lineTo(x-10, y+vertical_spacer);
		mc[name_down].endFill();
	}
	
}